{extend name="public/father" /}


{block name="main"}

<div style="max-width: 100%;margin: 20px;">
	<textarea rows="15" name="content" id="content" placeholder="请输入内容" class="layui-textarea"></textarea>
	<hr />
	<div style="text-align: center;">
		<button class="layui-btn" id="jiami">加密</button>
		<button class="layui-btn" id="jiemi">解密</button>
		<button class="layui-btn" id="tihuan">替换内容</button>
	</div>
	<hr />
	<textarea rows="15" name="jieguo" id="jieguo" placeholder="内容" class="layui-textarea"></textarea>
	<hr />
	<div>
				<pre class="layui-code" lay-title="" lay-height="" lay-skin="" lay-encode="">
function jiemi(s) {
	return decodeURIComponent(atob(s));
}

jiemi('JUU4JUJGJTk5JUU2JTk4JUFGJUU1JThFJTlGJUU1JUE3JThCJUU1JTg2JTg1JUU1JUFFJUI5');
				</pre>
	</div>
</div>

{/block}




{block name="js"}

<script>
	function jie(s) {
		return decodeURIComponent(atob(s));
	}

	function jia(s) {
		return btoa(encodeURIComponent(s));
	}

	$('#jiami').click(function() {
		var content = jia($('#content').val());
		console.log(content);
		$('#jieguo').val(content);
		return;
	});

	$('#jiemi').click(function() {
		var content = jie($('#content').val());
		console.log(content);
		$('#jieguo').val(content);
		return;
	});

	$('#tihuan').click(function() {
		var a, a1, a2;
		a1 = a = $('#content').val();
		a2 = $('#jieguo').val();

		$('#content').val(a2);
		$('#jieguo').val(a);

	});
</script>
{/block}
